package test_unitaire;

import static org.junit.Assert.assertTrue;

import java.util.Calendar;

import org.junit.Test;

import buisness_service.Depense;
import buisness_service.Finance_annee;
import buisness_service.Finance_jour;
import buisness_service.Finance_mois;
import buisness_service.Rapport;
import buisness_service.Rapport.Mois;
import buisness_service.User;

public class Test_Depense_jour {

	@Test
	public void testDepense_jour() {
		
		User u = new User();
		Finance_annee f_a = new Finance_annee(2008,u.getRapport());
		Finance_mois f = new Finance_mois(Mois.Mai, f_a, u);
		Finance_jour f_j = new Finance_jour(19, f,u);
		assertTrue(f_j.getDep_jour() == u.getRapport().get(0)
				.getDepense_annee().getDepenses_mois().get(0)
				.getDepenses_jour().get(0));

		Finance_jour f_j2 = new Finance_jour(20, f, u);
		assertTrue(f_j2.getDep_jour() == u.getRapport().get(0)
				.getDepense_annee().getDepenses_mois().get(0)
				.getDepenses_jour().get(1));

		Finance_mois f2 = new Finance_mois(Mois.Decembre, f_a,u);
		Finance_jour f_j3 = new Finance_jour(18, f2,u);
		assertTrue(f_j3.getDep_jour() == u.getRapport().get(0)
				.getDepense_annee().getDepenses_mois().get(1)
				.getDepenses_jour().get(0));
	
		Calendar d = Calendar.getInstance();
		d.set(2008, Calendar.DECEMBER, 18);
		Depense dep = new Depense(35,d, u );
		assertTrue(f_j3.getDep_jour().getDepenses().get(0)== dep);
		
		Rapport.postesDpenses.clear();
		Rapport.postesRevenus.clear();
	}

}
